# Loads config.ini file

import ConfigParser

def loadConfigFile():
    configInfo = {} # variable to store info from config file
    config = ConfigParser.SafeConfigParser()
    success = True # used to track if config file successfully loaded, we assume load is successful.
    try:
        config.readfp(open('config.ini'))
        if 'Database' in config.sections(): #database has to be one of the sections or something is wrong
            for section in config.sections():
                configInfo[section] = {}
                for option in config.options(section):
                    configInfo[section][option] = config.get(section, option)
        else:
            #start new wizard because config file is not right
            success = False
    except:
        print 'Error Loading Config File'
        success = False
    
    if not success: # loading of config file was not successful for one reason or another
        # start new wizard
        import newWizard
        newWizard.startWizard()
        
    return configInfo # return value of configInfo unless unsuccessful with loading config file AND starting new wizard, then return False

if __name__ == '__main__':
    import Tms
    Tms.Main()
